package com.yic.module.mes.dal.mysql.itemproduceroute;

import java.util.*;

import com.yic.framework.common.pojo.PageResult;
import com.yic.framework.mybatis.core.query.LambdaQueryWrapperX;
import com.yic.framework.mybatis.core.mapper.BaseMapperX;
import com.yic.module.mes.dal.dataobject.itemproduceroute.ItemProduceRouteDO;
import org.apache.ibatis.annotations.Mapper;
import com.yic.module.mes.controller.admin.itemproduceroute.vo.*;

/**
 * 产品工艺路线 Mapper
 *
 * @author 系统管理员
 */
@Mapper
public interface ItemProduceRouteMapper extends BaseMapperX<ItemProduceRouteDO> {

    default PageResult<ItemProduceRouteDO> selectPage(ItemProduceRoutePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<ItemProduceRouteDO>()
                .eqIfPresent(ItemProduceRouteDO::getItemProduceId, reqVO.getItemProduceId())
                .eqIfPresent(ItemProduceRouteDO::getRouteId, reqVO.getRouteId())
                .eqIfPresent(ItemProduceRouteDO::getDefaultRoute, reqVO.getDefaultRoute())
                .betweenIfPresent(ItemProduceRouteDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ItemProduceRouteDO::getId));
    }

    default List<ItemProduceRouteDO> selectList(ItemProduceRouteExportReqVO reqVO) {
        return selectList(new LambdaQueryWrapperX<ItemProduceRouteDO>()
                .eqIfPresent(ItemProduceRouteDO::getItemProduceId, reqVO.getItemProduceId())
                .eqIfPresent(ItemProduceRouteDO::getRouteId, reqVO.getRouteId())
                .eqIfPresent(ItemProduceRouteDO::getDefaultRoute, reqVO.getDefaultRoute())
                .betweenIfPresent(ItemProduceRouteDO::getCreateTime, reqVO.getCreateTime())
                .orderByDesc(ItemProduceRouteDO::getId));
    }

    default int deleteByItemProduceId(Long itemProduceId) {
        return delete(new LambdaQueryWrapperX<ItemProduceRouteDO>()
                .eq(ItemProduceRouteDO::getItemProduceId, itemProduceId));
    }

    default List<ItemProduceRouteDO> selectListByItemProduceId(Long itemProduceId) {
        return selectList(new LambdaQueryWrapperX<ItemProduceRouteDO>()
                .eq(ItemProduceRouteDO::getItemProduceId, itemProduceId));
    }

    default List<ItemProduceRouteDO> selectListByItemProduceId(Collection<Long> ids) {
        return selectList(new LambdaQueryWrapperX<ItemProduceRouteDO>()
                .in(ItemProduceRouteDO::getItemProduceId, ids));
    }

    default ItemProduceRouteDO selectOneByRouteId(Long routeId) {
        return selectOne(new LambdaQueryWrapperX<ItemProduceRouteDO>()
                .eq(ItemProduceRouteDO::getRouteId, routeId)
                .last("limit 1"));
    }
}
